import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'

const {resolve} = require('path')


export default ({mode}) => {
    const baseAPI = loadEnv(mode, process.cwd()).VITE_BASE_API

    console.log(baseAPI);
    return defineConfig({
        resolve: {
            alias: {
                '~@': resolve(__dirname, 'src') //把src改为@
            },
        },
        plugins: [vue()],
        server: {
            host: {
                hmr: true
            }
            /*proxy: {
                // 选项写法
                [baseAPI]: {
                    target: `http://localhost:8080`,
                    changeOrigin: true,
                    rewrite: (path) => path.replace(new RegExp(`^${baseAPI}`), '')
                }
            }*/
        }
    })
}



